package mq

type RocketMQ struct {
	producer *Producer
	consumer *Consumer
}

func NewMQ(server, topicSubs, topicPush, groupName string, receiver OnReceiver) *RocketMQ {
	c := &RocketMQ{
		consumer: nil,
		producer: nil,
	}
	c.producer = NewProducer(server, topicPush)
	c.consumer = NewConsumer(server, topicSubs, groupName, receiver)
	return c
}

func (this *RocketMQ) Send(json string) error {
	return this.producer.Send(json)
}

func (this *RocketMQ) Shutdown() {
	if this.producer != nil {
		this.producer.Shutdown()
	}
	if this.consumer != nil {
		this.consumer.Shutdown()
	}
}
